package com.labichaoka.chaoka.ui.baseinfo.idcard;

import com.labichaoka.chaoka.entity.BaseResponse;
import com.labichaoka.chaoka.entity.IDCardRequest;

/**
 * Created by ruan on 2018/8/3.
 */

public class IDCardPresenterImpl implements IDCardPresenter,IDCardInteractor.OnUploadFinishedListener{
    private IDCardInteractor idCardInteractor;
    private IDCardView view;

    public IDCardPresenterImpl(IDCardInteractor interactor,IDCardView v){
        this.idCardInteractor=interactor;
        this.view=v;
    }
    @Override
    public void upload(IDCardRequest request) {
        if (view!=null){
            view.showProgress();
        }
        idCardInteractor.uploadFile(request,this);
    }


    @Override
    public void onDestroy() {
        view=null;
    }

    @Override
    public void onUploadSuccessed(BaseResponse response) {
        view.hideProgress();
        view.goNext();
    }

    @Override
    public void onUploadFailed() {
        view.hideProgress();
    }
}
